// 基础设施 / 床位管理

import r from '@/utils/request'
import { type ListParams, type ListResponseType, type ResponseType } from '../types'

enum API {
    bedsList = "/beds/list", // 床位列表
    bedsAdd = "/beds/add", // 床位添加
    bedsUpdate = "/beds/update", // 床位修改
    bedsDelete = "/beds/delete", // 床位删除
    bedsDeleteAll = "/beds/deleteAll", // 床位批量删除
}

export interface bedsListParams extends ListParams{
    houseId:number
}

export interface bedsListResAPI {
    id:             number;
    companyId:      number;
    houseId:        number;
    name:           string;
    price:          number;
    state:          number;
    addTime:        string;
    addAccountId:   number;
    addAccountName: string;
}

export function getbedsListAPI(Params:ListParams):Promise<ListResponseType<bedsListResAPI[]>> {
    return r.get(API.bedsList,Params)
}

export interface  bedsAddAndUpdateParams {
    id:        number;
    houseId:   number;
    houseName: string;
    name:      string;
    price:     string;
    state:     number;
}

export interface bedsAddAndUpdateResAPI {
    id:             number;
    companyId:      number;
    houseId:        number;
    name:           string;
    price:          number;
    state:          number;
    addTime:        string;
    addAccountId:   number;
    addAccountName: string;
}

export function bedsAddAPI(Params:bedsAddAndUpdateParams):Promise<ResponseType<bedsAddAndUpdateResAPI>> {
    return r.post(API.bedsAdd,Params)
}

export function bedsUpdateAPI(Params:bedsAddAndUpdateParams):Promise<ResponseType<bedsAddAndUpdateResAPI>> {
    return r.put(API.bedsUpdate,Params)
}

export function bedsDeleteAPI(id:number):Promise<ResponseType<null>> {
    return r.delete(API.bedsDelete+'/'+id)
}

export function bedsDeleteAllAPI(ids:number[]):Promise<ResponseType<null>> {
    return r.post(API.bedsDeleteAll,ids)
}
